package hello.controller;

import hello.base.HttpResponse;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;


@Controller
@RequestMapping("/error")
public class ErrorCustomController {


    @RequestMapping(value = "/500")
    @ResponseBody
    public HttpResponse meet500() {
        HttpResponse r = new HttpResponse();
        r.setCode(500);
        r.setMsg("发生内部错误，请记录发生时间，并联系管理员解决");
        return r;
    }

    @RequestMapping(value = "/404")
    @ResponseBody
    public HttpResponse meet404() {
        HttpResponse r = new HttpResponse();
        r.setCode(404);
        r.setMsg("找不到资源，请核对请求地址");
        return r;
    }

    @RequestMapping(value = "/403")
    @ResponseBody
    public HttpResponse meet403() {
        HttpResponse r = new HttpResponse();
        r.setCode(403);
        r.setMsg("禁止外部访问");
        return r;
    }


    @RequestMapping(value = "/401")
    @ResponseBody
    public HttpResponse meet401() {
        HttpResponse r = new HttpResponse();
        r.setCode(401);
        r.setMsg("未获取访问权限，请重新登录");
        return r;
    }

    @RequestMapping(value = "/400")
    @ResponseBody
    public HttpResponse meet400() {
        HttpResponse r = new HttpResponse();
        r.setCode(400);
        r.setMsg("请求参数错误，请仔细核对参数");
        return r;
    }

}

